<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class B_sub_non_sy extends CI_Controller {

	function __construct() {
        parent::__construct();	
		$this->load->model("master/master_j_pendidikan");
		$this->load->model("bagi/bagi_non_syahriyah");
		$this->load->model("bagi/bagi_subsidi_non_syahriyah");
	}
	
	function index()
	{
		$data['judul'] = "Pembagian Susbsidi Non Syahriyah";
		$data['list'] = $this->bagi_subsidi_non_syahriyah->jenjang();		
		$data['main_view']='bagi/subsidi_non_syahriyah/jenjang';
		$this->load->view('index',$data);		
	}

	function tagihan($id_m_j_pendidikan)
	{
		$data['judul'] = "Pembagian Susbsidi Non Syahriyah";
		$data['list'] = $this->bagi_subsidi_non_syahriyah->tagihan($id_m_j_pendidikan);		
		$data['list_jp'] = $this->master_j_pendidikan->detail($id_m_j_pendidikan);		
		$data['main_view']='bagi/subsidi_non_syahriyah/tagihan';
		$this->load->view('index',$data);
	}

	function tholabah($id_a_non_sy)
	{
		$data['judul'] = "Pembagian Susbsidi Non Syahriyah";
		$data['list'] = $this->bagi_subsidi_non_syahriyah->tholabah($id_a_non_sy);
		$data['list_tag'] = $this->bagi_non_syahriyah->detail_tagihan($id_a_non_sy);
		$data['main_view']='bagi/subsidi_non_syahriyah/tholabah';
		$this->load->view('index',$data);
	}

	function subsidi()
	{
		$data['id_m_j_pendidikan'] = $id_m_j_pendidikan = $this->input->post('id_m_j_pendidikan');
		$data['list'] = $this->bagi_subsidi_non_syahriyah->subsidi();				
		$this->load->view('bagi/subsidi_non_syahriyah/ajax_subsidi',$data);
	}

	function sisa_dan_tholabah()
	{
		$id_a_subsidi = $this->input->post('id_a_subsidi');
		$id_a_non_sy = $this->input->post('id_a_non_sy');
		$data['list'] = $this->bagi_subsidi_non_syahriyah->sisa_subsidi($id_a_subsidi);
		$data['list_th'] = $this->bagi_subsidi_non_syahriyah->tholabah_blm_disubsidi($id_a_non_sy);	
		$this->load->view('bagi/subsidi_non_syahriyah/ajax_sisa_dan_tholabah',$data);
	}

	function save()
	{	
		$list_tholabah = $this->input->post('id_b_non_sy');

		if(isset($list_tholabah)){
			foreach($list_tholabah as $id_b_non_sy){
				$dataInsert = array(
					'id_b_non_sy' => $id_b_non_sy,
					'id_a_subsidi' => $this->input->post('id_a_subsidi'),
					'besar_subsidi' => $this->input->post('besar_subsidi')				
				);
			$this->bagi_subsidi_non_syahriyah->save($dataInsert);
			}
		}
	}

	function delete()
	{
		$id_b_sub_non_sy = $this->input->post('id_b_sub_non_sy');
		$this->bagi_subsidi_non_syahriyah->delete($id_b_sub_non_sy);
	}

	function refresh()
	{
		$id_a_non_sy = $this->security->xss_clean($this->uri->segment(3));
		$data['list'] = $this->bagi_subsidi_non_syahriyah->tholabah($id_a_non_sy);
		$data['list_tag'] = $this->bagi_non_syahriyah->detail_tagihan($id_a_non_sy);
		$this->load->view('bagi/subsidi_non_syahriyah/refresh',$data);
	}

	function refresh_jml()
	{
		$id_a_non_sy = $this->security->xss_clean($this->uri->segment(3));
		$data['list'] = $this->bagi_subsidi_non_syahriyah->tholabah($id_a_non_sy);
		$this->load->view('bagi/subsidi_non_syahriyah/refresh_jml',$data);
	}

}